package com.itany.corejava.day04;

import java.util.Arrays;

public class Test7 {

    public static void main(String[] args) {
        
        int[] arr;
//        int a[];


        /*
            1.分配空间
            2.自动数据初始化
            3.将空间的首地址赋值给arr
         */
        arr=new int[4];
        System.out.println("arr = " + arr);

        System.out.println("arr[1] = " + arr[1]);

        arr[3]=6;

        System.out.println("arr[3] = " + arr[3]);

        //数组的静态初始化
//        int[] arr2=new int[]{1,34,6,34,76,23,45};
        int[] arr2={1,34,6,34,76,23,45};



        System.out.println("arr2 = " + arr2);

        System.out.println("arr2.length = " + arr2.length);

//        for (int i = 0; i < arr2.length; i++) {
//            System.out.println(arr2[i]);
//        }
        System.out.println("Arrays.toString(arr2) = " + Arrays.toString(arr2));

        //错，{}只能作为静态初始化使用，不能修改值
//        arr2={1,2,3,4,5,6,7};
        arr2=new int[]{1,2,3,4,5,6,7};
        System.out.println("arr2 = " + arr2);





    }
    
}
